import turtle

# 设置画布
screen = turtle.getscreen()
screen.title("画多边形")

# 设置画笔
pen = turtle.getpen()
pen.shape("turtle")
pen.speed(0) # 速度：0是最快、10是较快、6是正常、3是较慢、1是最慢

def draw_regular_polygon(sides):
    for i in range(sides):
        pen.forward(1000 / sides)
        pen.left(360 / sides)

### 画图开始 ###

while True:
    pen.teleport(200, -200)
    pen.setheading(90)

    sides = int(input("请输入多边形的边数："))
    pen.clear()
    pen.teleport(-1000 / sides / 2, -1000 / 2 /3.14)
    pen.setheading(0)

    if sides <= 0:
        print("边数不能小于0哦！")
    elif sides < 3:
        print("多边形的边数必须大于等于3！")
    elif sides <= 50:
        draw_regular_polygon(sides)
    else:
        pen.circle(1000 / 2 / 3.14)

### 画图结束 ###

# 收笔
pen.hideturtle()
# 持续显示
screen.mainloop()